\documentclass[tikz,border=3pt]{standalone}
\usepackage{amsmath}
\usepackage{fontspec} % 确保中文支持
\setmainfont{SimSun} % 选择适合的中文字体

\begin{document}
	
	\begin{tikzpicture}[scale=0.9, every node/.style={font=\small}]
		% 定义公共参数
		\def\xmin{-0.5}
		\def\xmax{4}
		\def\ymin{-0.5}
		\def\ymax{4}
		\def\xa{0.8}
		\def\xb{3.0} % 增大间距
		\def\mida{1.9}  % 调整中点位置
		
		% 凹函数示意图 (a)
		\begin{scope}[shift={(0,0)}]
			% 坐标系
			\draw[->] (\xmin,0) -- (\xmax,0) node[right] {$x$};
			\draw[->] (0,\ymin) -- (0,\ymax) node[above] {$y$};
			\node[below left] at (0,0) {$O$};
			
			% 凹函数曲线
			\draw[blue, thick] plot[smooth, domain=0.5:3.5] (\x, {-\x*\x/3 + 2*\x - 0.5});
			\node[blue, above] at (1.2,2.0) {\textbf{(a)}};
			
			% 函数计算
			\pgfmathsetmacro{\funcA}{-\xa*\xa/3 + 2*\xa - 0.5}
			\pgfmathsetmacro{\funcB}{-\xb*\xb/3 + 2*\xb - 0.5}
			\pgfmathsetmacro{\funcMid}{-\mida*\mida/3 + 2*\mida - 0.5}
			\pgfmathsetmacro{\funcAvg}{(\funcA + \funcB)/2}
			
			% 标记点
			\coordinate (A) at (\xa, \funcA);
			\coordinate (B) at (\xb, \funcB);
			\coordinate (Mid) at (\mida, \funcMid);
			\coordinate (Avg) at (\mida, \funcAvg);
			
			% 垂直线
			\draw[dashed, gray] (\xa,0) -- (A);
			\draw[dashed, gray] (\xb,0) -- (B);
			\draw[dashed, gray] (\mida,0) -- (Mid);
			
			% 水平线（弦）
			\draw[dashed, gray] (A) -- (B);
			
			% 标注x轴点（移到轴线下方）
			\node[below] at (\xa,0) {$x_1$};
			\node[below] at (\xb,0) {$x_2$};
			\node[below] at (\mida,0) {$\dfrac{x_1 + x_2}{2}$};
			
			% 标注函数值（使用偏移位置）
			\node[left, yshift=-2pt] at (0, \funcA) {$f(x_1)$};
			\node[right, yshift=2pt] at (0, \funcB) {$f(x_2)$};
			
			% 关键点标记（使用颜色区分）
			\fill[red] (Mid) circle (1.5pt);
			\node[red, below right, xshift=2pt] at (Mid) {$f\left(\dfrac{x_1 + x_2}{2}\right)$};
			
			\fill[green!70!black] (Avg) circle (1.5pt);
			\node[green!70!black, below, yshift=-2pt] at (Avg) {\small $\dfrac{f(x_1) + f(x_2)}{2}$};
			
			% 连接线（细线避免干扰）
			\draw[dashed, green!50!black, thin] (A) -- (Avg);
			\draw[dashed, green!50!black, thin] (B) -- (Avg);
			
		\end{scope}
		
		% 凸函数示意图 (b)
		\begin{scope}[shift={(6.5,0)}] % 增加间距
			% 坐标系
			\draw[->] (\xmin,0) -- (\xmax,0) node[right] {$x$};
			\draw[->] (0,\ymin) -- (0,\ymax) node[above] {$y$};
			\node[below left] at (0,0) {$O$};
			
			% 凸函数曲线
			\draw[red, thick] plot[smooth, domain=0.5:3.5] (\x, {\x*\x/3 - \x + 2});
			\node[red, above] at (4.2,2.0) {\textbf{(b)}};
			
			% 函数计算
			\pgfmathsetmacro{\funcA}{\xa*\xa/3 - \xa + 2}
			\pgfmathsetmacro{\funcB}{\xb*\xb/3 - \xb + 2}
			\pgfmathsetmacro{\funcMid}{\mida*\mida/3 - \mida + 2}
			\pgfmathsetmacro{\funcAvg}{(\funcA + \funcB)/2}
			
			% 标记点
			\coordinate (A) at (\xa, \funcA);
			\coordinate (B) at (\xb, \funcB);
			\coordinate (Mid) at (\mida, \funcMid);
			\coordinate (Avg) at (\mida, \funcAvg);
			
			% 垂直线
			\draw[dashed, gray] (\xa,0) -- (A);
			\draw[dashed, gray] (\xb,0) -- (B);
			\draw[dashed, gray] (\mida,0) -- (Mid);
			
			% 水平线（弦）
			\draw[dashed, gray] (A) -- (B);
			
			% 标注x轴点（移到轴线下方）
			\node[below] at (\xa,0) {$x_1$};
			\node[below] at (\xb,0) {$x_2$};
			\node[below] at (\mida,0) {$\dfrac{x_1 + x_2}{2}$};
			
			% 标注函数值（使用偏移位置）
			\node[left, yshift=2pt] at (0, \funcA) {$f(x_1)$};
			\node[right, yshift=-2pt] at (0, \funcB) {$f(x_2)$};
			
			% 关键点标记（使用颜色区分）
			\fill[blue] (Mid) circle (1.5pt);
			\node[blue, above left, xshift=-2pt] at (Mid) {$f\left(\dfrac{x_1 + x_2}{2}\right)$};
			
			\fill[purple] (Avg) circle (1.5pt);
			\node[purple, above, yshift=2pt] at (Avg) {\small $\dfrac{f(x_1) + f(x_2)}{2}$};
			
			% 连接线（细线避免干扰）
			\draw[dashed, purple, thin] (A) -- (Avg);
			\draw[dashed, purple, thin] (B) -- (Avg);
			
		\end{scope}
		
		% 添加图例框
		\begin{scope}[shift={(1.5,4.0)}]
			\draw[fill=white, fill opacity=0.8] (-0.5,0) rectangle (3.5,-1.2);
			\fill[green!70!black] (0,-0.3) circle (1.5pt);
			\node[right] at (0.3,-0.3) {\small 平均值点};
			\fill[red] (0,-0.7) circle (1.5pt);
			\node[right] at (0.3,-0.7) {\small 中点函数值点};
			%\draw[black, dashed] (2.0,-0.3) -- (2.8,-0.3);
			%\node[right] at (3.0,-0.3) {\small 弦线};
		\end{scope}
	\end{tikzpicture}
	
\end{document}